package cn.edu.sgu.www.mhxysy.controller.children;

import cn.edu.sgu.www.mhxysy.consts.CustomConstants;
import cn.edu.sgu.www.mhxysy.consts.CustomMessages;
import cn.edu.sgu.www.mhxysy.consts.MimeTypes;
import cn.edu.sgu.www.mhxysy.entity.children.ChildrenViewZizhi;
import cn.edu.sgu.www.mhxysy.restful.JsonResult;
import cn.edu.sgu.www.mhxysy.service.children.ChildrenViewZizhiService;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Api(tags = "子女预览资质管理")
@ApiSupport(author = CustomConstants.AUTHOR)
@Validated
@RestController
@RequestMapping(path = "/children_view_zizhi", produces = MimeTypes.APPLICATION_JSON_CHARSET_UTF_8)
public class ChildrenViewZizhiController {

    private final ChildrenViewZizhiService childrenViewZizhiService;

    @Autowired
    public ChildrenViewZizhiController(ChildrenViewZizhiService childrenViewZizhiService) {
        this.childrenViewZizhiService = childrenViewZizhiService;
    }

    @ApiOperation("通过子女ID查询子女预览资质")
    @RequestMapping(value = "/selectByChildrenId", method = RequestMethod.GET)
    public JsonResult<ChildrenViewZizhi> selectByChildrenId(
            @ApiParam(name = "childrenId", value = "子女ID", required = true)
            @NotBlank(message = CustomMessages.ID_NOT_NULL) String childrenId) {
        ChildrenViewZizhi childrenViewZizhi = childrenViewZizhiService.selectByChildrenId(childrenId);

        return JsonResult.success(null, childrenViewZizhi);
    }

}